// **********************************************************************
//                            Project Nitro
//                        ---------------------
//
//  File        : Level.h
//  Description : Level
//  Author      : Guillaume Delhumeau <guillaume.delhumeau@gmail.com>
//  License     : GNU General Public License 3
//
// **********************************************************************

#ifndef _LEVEL_H_
#define _LEVEL_H_

#include <string>
#include <vector>
#include <ClanLib/core.h>
#include "Screen.h"

class Tile;
class MapElement;

class Level{

public:
	Level();
	~Level();

	void load_level_file(std::string filename, Screen & screen);	

	inline MapElement & get_map_tile(int col, int row){ return *_map[col+_nb_cols*row]; }

	void draw(Screen & screen, float scroll_x, float scroll_y);

	inline int get_nb_cols() const {return _nb_cols;}

	inline int get_nb_rows() const {return _nb_rows;}

	inline int get_tiles_width() const {return _tiles_width;}

	inline int get_tiles_height() const {return _tiles_height;}

	inline int get_map_width() const {return _nb_cols * _tiles_width;}

	inline int get_map_height() const {return _nb_rows * _tiles_height;}

private:

	int _tiles_width;
	int _tiles_height;

	int _nb_cols;
	int _nb_rows;	

	std::vector<Tile*> _tiles;

	std::vector<MapElement*> _map;

	void _load_tiles(CL_DomElement root, Screen & screen, CL_VirtualDirectory & vd);

	void _load_map(CL_DomElement root);

	Tile* _get_tile_from_id(CL_String id);

	void _unload();

};

#endif
